package com.tanhua.server.task;

import com.tanhua.commons.SoulConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

@Component
@Slf4j
public class RedisTask {

    @Autowired
    private RedisTemplate<String,String> redisTemplate;


    @Scheduled(cron = "0 0 0 * * ? ")
    public void removeTimeInRedis() {
        String sendKey = SoulConstants.SEND_SOUND_TIMES + "*";
        String receiveKey = SoulConstants.GET_SOUND_TIMES + "*";
        List<String> keys = Arrays.asList(sendKey, receiveKey);
        redisTemplate.delete(keys);
        log.info("删除语音次数成功");
    }
}
